import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/data/store/config_store.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:bxultimate/widgets/mk_scroll_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class HonourCardApplyPage extends StatefulWidget {
  const HonourCardApplyPage({Key? key}) : super(key: key);

  @override
  State<HonourCardApplyPage> createState() => _HonourCardApplyPageState();
}

class _HonourCardApplyPageState extends State<HonourCardApplyPage> {
  final controller = Get.find<HonourCardApplyController>();
  final state = Get.find<HonourCardApplyController>().state;

  _buildBottom() {
    return Container(
      // padding: EdgeInsets.symmetric(vertical: AppTheme.iDefaultPadding),
      decoration: BoxDecoration(color: Colors.white),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Gaps.hGap12,
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text(
                '￥',
                style: TextStyle(fontSize: 16),
              ),
              Text(
                '10',
                style: TextStyle(
                    fontSize: 24,
                    color: Colors.redAccent,
                    fontWeight: FontWeight.bold),
              ),
            ],
          ),
          Gaps.hGap12,
          Text(
            '邮费10元',
            style: TextStyle(fontSize: 14, color: Color(0xFF606266)),
          ),
          Gaps.hGap12,
          Expanded(
              child: TDButton(
            text: '立即支付',
            height: 50,
            textStyle: TextStyle(fontSize: 16),
            size: TDButtonSize.small,
            theme: TDButtonTheme.primary,
            shape: TDButtonShape.filled,
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MkPage(
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          title: Text('领取戎耀牌'),
        ),
        body: MkScrollView(
          bottomButton: _buildBottom(),
          children: [
            boxWrap(ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: MkLoadImage(
                  ConfigStore.to.baseFileUrl + Get.arguments['image']),
            )),
            Gaps.vGap12,
            boxWrap(Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '戎耀驿站标牌',
                      style:
                          TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
                    ),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Text(
                          '￥',
                          style: TextStyle(fontSize: 16),
                        ),
                        Text(
                          '10',
                          style: TextStyle(
                              fontSize: 24,
                              color: Colors.redAccent,
                              fontWeight: FontWeight.bold),
                        ),
                      ],
                    ),
                  ],
                ),
                Gaps.vGap8,
                Text('176mm×250mm，可粘贴')
              ],
            )),
            Gaps.vGap12,
            Padding(
              padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding),
              child: TDRadioGroup(
                selectId: '1',
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    TDRadio(
                      id: '1',
                      title: '自取',
                      subTitle: '取货地址：山西省太原市杏花岭区旱西北一条与柳溪街交叉口南120米\n联系方式：15903465951',
                      subTitleMaxLine: 3,
                    ),
                    TDRadio(
                      id: '2',
                      title: '邮寄',
                      subTitle: '省内邮寄需快递费10元',
                      subTitleMaxLine: 3,
                    ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding),
              child: TDCell(
                title: '收货地址',
                description: '请填写收货地址',
                arrow: true,
              ),
            ),
            Gaps.vGap12,
            boxWrap(Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('申请须知',style: TextStyle(color: Colors.redAccent,fontSize: 18,fontWeight: FontWeight.bold),),
                Gaps.vGap8,
                Text('1、商家在使用兵馨APP的过程中应遵守国家法律法规及政策规定，对制作、上传、发送、传播的信息和内容承担法律责任；'),
                Text('2、商家需承诺为各类优抚对象提供真实有效的折扣优惠，诚信经营；'),
                Text('3、“戎创实体”军创实体店实体牌照申请，需上传商家营业执照及法人退役军人优待证，经平台审核通过后发放牌照，牌照工本费10元，邮寄费按照实际费用收取；'),
                Text('4、平台若发现商家存在不法经营、不诚信经营等违反平台规定的行为，平台有权收回此牌照。')
              ],
            ))
          ],
        ),
      ),
    );
  }

  Widget boxWrap(child) {
    return Container(
      width: double.infinity,
      margin: EdgeInsets.only(
          left: AppTheme.iDefaultPadding, right: AppTheme.iDefaultPadding),
      padding: EdgeInsets.all(AppTheme.iDefaultPadding),
      decoration: BoxDecoration(color: Colors.white),
      child: child,
    );
  }

  @override
  void dispose() {
    Get.delete<HonourCardApplyController>();
    super.dispose();
  }
}
